//教学流程
var TeachFlow05 = cc.Class.extend({
	step:0,
	flow:null,
	scene:null,
	tip:null,
	tip_frame:null,
	flash:null,
	// 结束标志
	over_flag: false,
	curSprite:null,
	ctor: function(scene){
		this.scene=scene;
	},
	init: function(tip, tip_frame, flash){
		this.tip = tip;
		this.flash = flash;
		for(var i in gg.teachFlow){
			gg.teachFlow[i].finish = false;
			gg.teachFlow[i].cur = false;
			gg.teachFlow[i].id = i - -1;
			if(gg.teachFlow[i].action == null){
				gg.teachFlow[i].action = ACTION_NONE;				
			}
			if(gg.teachFlow[i].lock == null){
				gg.teachFlow[i].lock = true;
			}
		}
	},
	start:function(){
		this.over_flag = false;
		this.step = 0;
	},
	over:function(){
		this.over_flag = true;
		this.flow = over;
		this.scene.over();
	},
	checkTag:function(tag){
		var cur_flow = gg.teachFlow[this.step - 1];
		if(cur_flow.tag == tag){
			return true;
		} else {
			return false;
		}
	},
	prev:function(count){
		if(this.curSprite!=null){
			this.curSprite.stop();
			this.curSprite = null;
		}
		if(this.flow!=null){
			this.flow.cur = false;
		}
		this.step = this.step - count;
		this.flow = gg.teachFlow[this.step - 1];
		this.refresh();
	},
	// 执行下一个任务
	next:function(){
		// 流程结束
		if(this.over_flag){
			return;
		}
		if(this.curSprite!=null){
			this.curSprite.stop();
			this.curSprite = null;
		}
		if(this.flow!=null){
			this.flow.cur = false;
			// 标记任务已完成
			this.flow.finish = true;
		}
		this.flow = gg.teachFlow[this.step++];
		if(this.flow.finish){
			// 如果任务已完成，跳过当前步骤
			this.next();
		}
		this.refresh();
	},
	refresh:function(){
		// 刷新提示
		this.flow.cur = true;
		if(this.flow.tip != null){
			this.tip.doTip(this.flow.id + "." + this.flow.tip);
		}
		if(this.flow.flash != null){
			this.flash.doFlash(this.flow.flash);
		}
		if(this.step > gg.teachFlow.length - 1){
			this.over();
			
		}
		this.initCurSprite();
		if(this.curSprite!=null){
			this.location();
			this.curSprite.setEnable(true);
		}
		var before = gg.teachFlow[this.step - 2];
		if(before == null || before.lock){
			synch_listener = true;
		}
	},
	getStep:function(){
		return this.step;
	},
	location:/**
	 * 定位箭头
	 */
		function(){
//		this.scene.tipLayer.arr.pos(this.curSprite);
		ll.tip.arr.pos(this.curSprite);
	},
	initCurSprite:function(){
		var tag = this.flow.tag;
		var scene=this.scene;
		var layer = this.scene.mainLayer;
		var arrayTag = 
			[TAG_G5_PLAYMAIN,TAG_G5_COMP,TAG_G5_APPARATUS
			 ,TAG_G5_AIRPUMP,TAG_G5_BOTTLE1,TAG_G5_BOTTLE2
			];
		for(var i = 0; i < arrayTag.length; i++){
			var at = arrayTag[i];
			var layer1=this.scene.getChildByTag(at);
			if(layer1==null){
				var root=layer.getChildByTag(at);
				if(root==null){
					continue;
				}else{
				var sprite = null;
				sprite = root.getChildByTag(tag);
				if(sprite != null){
					if(this.flow.base != null && this.flow.base != at){
						continue;
					}
					this.curSprite = sprite;	
					return;
				}
			}
			}else{
				var sprite = null;
				sprite = layer1.getChildByTag(tag);
					if(sprite != null){
						if(this.flow.base != null && this.flow.base != at){
							continue;
						}
						this.curSprite = sprite;	
						return;
				}
			}	
		}
	}
});
// 任务流
teachFlow05 = [
       {tip:"检查气路管线",tag:TAG_ITEM_PNEUMATIC,finish:false,action:ACTION_NONE,lock:true},
       {tip:"检查电源线",tag:TAG_ITEM_POWERLINE},
       {tip:"检查信号线",tag:TAG_ITEM_SIGNALLINE},
       {tip:"点击G5气相色谱仪,来到气相色谱仪界面",tag:TAG_ITEM_APPARATUS,action:ACTION_DO1},
       {tip:"点击G5气相色谱仪,打开箱门",tag:TAG_ITEM_APPARATUS4,action:ACTION_DO1},
       {tip:"检查色谱柱是否安装",tag:TAG_ITAM_CHROMATOGRAPHIC},
       {tip:"点击G5气相色谱仪,关闭箱门",tag:TAG_ITEM_APPARATUS5},
       {tip:"点击G5气相色谱仪,来到气相色谱仪界面",tag:TAG_ITEM_APPARATUS,action:ACTION_DO3},
       {tip:"点击G5气相色谱仪,打开气相色谱仪顶部",tag:TAG_ITEM_APPARATUS2},
       {tip:"点击电脑来到电脑界面",tag:TAG_ITEM_COMPCLOSE},    
       {tip:"点击电脑开机按钮打开电脑",tag:TAG_ITEM_OPENCOMP},
       {tip:"点击气瓶柜门把打开气瓶柜",tag:TAG_ITEM_CUPBOARD},
       {tip:"点击载气瓶,来到载气瓶界面",tag:TAG_ITEM_BOTTLE1},
       {tip:"逆时针旋转载气瓶的主阀门",tag:TAG_ITEM_BOTTLE1_TOP,action:ACTION_DO1},
       {tip:"查看载气瓶上的主压显示器显示的气压是否在3-4Mpa之间",tag:TAG_ITEM_BOTTLE1_TOP,action:ACTION_DO2},
       {tip:"查看载气瓶上的分压显示器显示的气压是否为0.3Mpa",tag:TAG_ITEM_BOTTLE1_TOP,action:ACTION_DO3},
       {tip:"点击氢气瓶,来到氢气瓶界面",tag:TAG_ITEM_BOTTLE2},
       {tip:"逆时针旋转氢气瓶的主阀门",tag:TAG_ITEM_BOTTLE2_TOP,action:ACTION_DO1},
       {tip:"查看氢气瓶上的分压显示器显示的气压是否为0.2Mpa",tag:TAG_ITEM_BOTTLE2_TOP,action:ACTION_DO2},
       {tip:"打开空气泵",tag:TAG_ITEM_AIRPUMP},
       {tip:"点击空气泵开关打开空气泵",tag:TAG_BUTTON_AIRPUMPOPEN},
       {tip:"点击G5气相色谱仪,来到气相色谱仪右侧",tag:TAG_ITEM_APPARATUS1,action:ACTION_DO1},
       {tip:"点击气相色谱仪按钮,打开气相色谱仪",tag:TAG_BUTTON_APPARATUSOPEN},
       {tip:"点击气相色谱仪显示器,查看是否进入菜单界面",tag:TAG_ITEM_DISPLAY,action:ACTION_DO1},
       {tip:"点击打开的电脑",tag:TAG_ITEM_COMPOPEN,action:ACTION_DO1},
       {tip:"点击电脑屏幕上的气相色谱软件按钮打开软件",tag:TAG_ITEM_SOFTWARE},
       {tip:"展开收起面板",tag:TAG_BUTTON_SHOW},
       {tip:"点击柱箱温度设定框，将温度设定为100℃",tag:TAG_BUTTON_SETNUM,action:ACTION_DO1},
       {tip:"点击确定按钮",tag:TAG_BUTTON_HEATSURE,action:ACTION_DO1},
       {tip:"点击加热按钮，进行加热",tag:TAG_BUTTON_HEAT,action:ACTION_DO1},
       {tip:"点击前进样器温度设定框，将温度设定为200℃",tag:TAG_BUTTON_SETNUM,action:ACTION_DO2},
       {tip:"点击确定按钮",tag:TAG_BUTTON_HEATSURE,action:ACTION_DO2},
       {tip:"点击加热按钮,进行加热",tag:TAG_BUTTON_HEAT,action:ACTION_DO2},
       {tip:"点击前检测器温度设定框，将温度设定为250℃",tag:TAG_BUTTON_SETNUM,action:ACTION_DO3},
       {tip:"点击确定按钮",tag:TAG_BUTTON_HEATSURE,action:ACTION_DO3},
       {tip:"点击加热按钮，进行加热",tag:TAG_BUTTON_HEAT,action:ACTION_DO3},
       {tip:"点击气相色谱仪,打开气相色谱仪界面",tag:TAG_ITEM_APPARATUS3,action:ACTION_DO1},
       {tip:"点击气相色谱仪,打开气相色谱仪左侧箱门",tag:TAG_ITEM_APPARATUS7,action:ACTION_DO1},
       {tip:"旋转旋钮,将空气旋钮旋转到5.5圈",tag:TAG_ITEM_KNOB},
       {tip:"旋转旋钮,将氢气旋钮旋转到6圈",tag:TAG_ITEM_KNOB1},
       {tip:"点击气相色谱仪显示器,查看仪器各部位温度是否符合条件",tag:TAG_ITEM_DISPLAY,action:ACTION_DO2},
       {tip:"点击打开的电脑",tag:TAG_ITEM_COMPSOFTWARE,action:ACTION_DO1},
       {tip:"点击检测器按钮,打开检测界面",tag:TAG_BUTTON_DETECTION},
       {tip:"点击A路点火,持续10分钟",tag:TAG_BUTTON_IGNITION}, 
       {tip:"点击打开的电脑",tag:TAG_ITEM_COMPSOFTWARE1,action:ACTION_DO1},
       {tip:"点击新建任务按钮新建任务",tag:TAG_BUTTON_ADDPLAN},
       {tip:"点击确定",tag:TAG_BUTTON_PLANSURE,action:ACTION_DO1},
       {tip:"点击新建按钮,添加样品信息",tag:TAG_BUTTON_ADD,action:ACTION_DO1},
       {tip:"选择分析次数",tag:TAG_BUTTON_SELECTED1,action:ACTION_DO1},
       {tip:"输入自动结束时间",tag:TAG_BUTTON_TIME,action:ACTION_DO1},
       {tip:"选择相应的样品类型",tag:TAG_BUTTON_SELECTED2,action:ACTION_DO1},
       {tip:"点击确认",tag:TAG_BUTTON_PLANSURE,action:ACTION_DO2},
       {tip:"点击进样1",tag:TAG_BUTTON_SET,action:ACTION_DO1},
       {tip:"打开试剂瓶",tag:TAG_ITEM_CAP,action:ACTION_DO1},
       {tip:"点击进样针,慢慢抽取无水乙醇",tag:TAG_ITEM_SQUIRT,action:ACTION_DO1},
       {tip:"点击进样针,查看进样针内是否含有气泡",tag:TAG_ITEM_SQUIRT1,action:ACTION_DO4},
       {tip:"将进样针内溶液快速推出,去除进样针内气泡",tag:TAG_ITEM_SQUIRT1,action:ACTION_DO1},
       {tip:"点击进样针,慢慢抽取无水乙醇",tag:TAG_ITEM_SQUIRT2,action:ACTION_DO1},
       {tip:"用纸巾擦去进样针针筒部位的液体",tag:TAG_ITEM_PAPERITEM,action:ACTION_DO1},
       {tip:"将进样针插入进样口1,进样针保持垂直,快进快出",tag:TAG_ITEM_SQUIRT3,action:ACTION_DO1},
       {tip:"点击电脑,来到软件界面",tag:TAG_ITEM_COMPSOFTWARE2,action:ACTION_DO1},
       {tip:"点击开始进样按钮,开始进样",tag:TAG_BUTTON_SAMPLING,action:ACTION_DO1},
       {tip:"点击进样2,使用进样针抽取溶液进样",tag:TAG_BUTTON_SET,action:ACTION_DO2},
       {tip:"点击电脑,进入软件界面",tag:TAG_ITEM_COMPSOFTWARE2,action:ACTION_DO2},
       {tip:"点击开始进样按钮,开始进样",tag:TAG_BUTTON_SAMPLING,action:ACTION_DO2},
       {tip:"点击进样3,使用进样针抽取溶液进样",tag:TAG_BUTTON_SET,action:ACTION_DO3},
       {tip:"盖上试剂瓶盖子",tag:TAG_ITEM_CAP,action:ACTION_DO2},
       {tip:"点击电脑,进入软件界面",tag:TAG_ITEM_COMPSOFTWARE2,action:ACTION_DO3},
       {tip:"点击开始进样按钮,开始进样",tag:TAG_BUTTON_SAMPLING,action:ACTION_DO3},
       {tip:"点击新建按钮,添加样品信息",tag:TAG_BUTTON_ADD,action:ACTION_DO2},
       {tip:"选择分析次数",tag:TAG_BUTTON_SELECTED1,action:ACTION_DO2},
       {tip:"输入自动结束时间",tag:TAG_BUTTON_TIME,action:ACTION_DO2},
       {tip:"选择相应的样品类型",tag:TAG_BUTTON_SELECTED2,action:ACTION_DO2},
       {tip:"点击确认",tag:TAG_BUTTON_PLANSURE,action:ACTION_DO3},
       {tip:"点击进样1",tag:TAG_BUTTON_SET,action:ACTION_DO4},
       {tip:"打开安捷伦进样瓶瓶盖",tag:TAG_ITEM_VESSEL},
       {tip:"点击进样针,慢慢抽取安捷伦进样瓶中的试样",tag:TAG_ITEM_SQUIRT,action:ACTION_DO3},
       {tip:"将进样针内试样快速推出进样针,用于润洗进样针,重复动作5次",tag:TAG_ITEM_SQUIRT1,action:ACTION_DO3},
       {tip:"点击进样针,慢慢抽取安捷伦进样瓶中的试样",tag:TAG_ITEM_SQUIRT,action:ACTION_DO5},
       {tip:"用纸巾擦去进样针针筒部位的液体",tag:TAG_ITEM_PAPERITEM,action:ACTION_DO2},
       {tip:"将进样针内试样通过进样口注入到仪器内部",tag:TAG_ITEM_SQUIRT1,action:ACTION_DO2},
       {tip:"点击电脑,进入软件界面",tag:TAG_ITEM_COMPSOFTWARE3},
       {tip:"点击开始进样按钮,开始进样",tag:TAG_BUTTON_SAMPLING,action:ACTION_DO4},
       {tip:"点击进样2,使用进样针抽取溶液进样",tag:TAG_BUTTON_SET,action:ACTION_DO5},
       {tip:"点击电脑,进入软件界面",tag:TAG_ITEM_COMPSOFTWARE3},
       {tip:"点击开始进样按钮,开始进样",tag:TAG_BUTTON_SAMPLING,action:ACTION_DO5},
       {tip:"点击进样3,使用进样针抽取溶液进样",tag:TAG_BUTTON_SET,action:ACTION_DO6},
       {tip:"点击电脑,进入软件界面",tag:TAG_ITEM_COMPSOFTWARE3},
       {tip:"点击开始进样按钮,开始进样",tag:TAG_BUTTON_SAMPLING,action:ACTION_DO6},
       {tip:"点击氢气钢瓶,进入氢气钢瓶界面",tag:TAG_ITEM_BOTTLE2,action:ACTION_DO1},
       {tip:"顺时针旋转阀门，关闭氢气钢瓶",tag:TAG_ITEM_BOTTLE2_TOP,action:ACTION_DO3},
       {tip:"点击空气泵,来到空气泵界面",tag:TAG_ITEM_AIRPUMP,action:ACTION_DO1},
       {tip:"点击空气泵开关，关闭空气泵",tag:TAG_BUTTON_AIRPUMPCLOSE},
       {tip:"点击电脑来到电脑界面",tag:TAG_ITEM_COMPSOFTWARE3,action:ACTION_DO2},    
       {tip:"点击电脑开机按钮关闭电脑,并等待温度降到指定温度后",tag:TAG_ITEM_CLOSECOMP},
       {tip:"点击气相色谱仪，进入气相色谱仪侧面",tag:TAG_ITEM_APPARATUS9,action:ACTION_DO1},
       {tip:"点击气相色谱仪开关,关闭气相色谱仪",tag:TAG_BUTTON_APPARATUSCLOSE},
       {tip:"点击载气瓶,进入载气瓶界面",tag:TAG_ITEM_BOTTLE1,action:ACTION_DO1},
       {tip:"顺时针旋转阀门,关闭载气瓶",tag:TAG_ITEM_BOTTLE1_TOP,action:ACTION_DO4},

       {tip:"恭喜过关",over:true}
       ];
over = {tip:"恭喜过关"};



